<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Geo</title>

<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport"/>
<form name="geoform" action="#" method="POST">
{% csrf_token %} 
</form>

<script>

navigator.geolocation.getCurrentPosition(function handler(location) {
        var message = document.getElementById("message");
        var lon = document.createElement('input');
        lon.setAttribute('name','longitude');
        lon.setAttribute('type','hidden');
        lon.setAttribute('value',location.coords.longitude);
        document.geoform.appendChild(lon);

        var lat = document.createElement('input');
        lat.setAttribute('name','latitude');
        lat.setAttribute('type','hidden');
        lat.setAttribute('value',location.coords.latitude);
        document.geoform.appendChild(lat);

        document.geoform.submit();
});

</script>
</head>
<body>
<div id="message">Detecting Location...</div>

<a href=".">Reload</a>
</body>
</html>
